<?php $this->load->view('config/header');?>
<h2>Form <?php echo $mode?></h2>
<div class="line-separtor"></div>
<br/>	
	<a href="<?php echo site_url()?>settingmenu" class="btn btn-primary"> Kembali ke daftar </a>
<br/>
<br/>
<script type="text/javascript">
	var group_id = '<?php echo @$detail[0]['group_menu']?>';
	
	var master_id = '<?php echo @$detail[0]['master_menu']?>';

	$(document).ready(function(){
		if(group_id){
			if(group_id == 1){
				$("#advanceSet").show();
			}else{
				$("#advanceSet").hide();
			}
		}else{
			$("#advanceSet").hide();
		}
		
		if(master_id){
			if(master_id == 1 || master_id == ""){
				$("#groupmenu").val('');
				$("#mastermenu").val('');
				$("#advanceSet").hide();
				$("#advanceGroupSet").hide();
			}else{
				$("#advanceGroupSet").show();
			}
		}else{
			$("#groupmenu").val('');
			$("#mastermenu").val('');
			$("#advanceSet").hide();
			$("#advanceGroupSet").hide();
		}
	});
	
	function getNilai(v){
		if(v == 1 || group_id == 1){
			$("#advanceSet").show();
		}else{
			$("#mastermenu").val('');
			$("#advanceSet").hide();
		}
	}
	
	function getNilaiMaster(v){
		if(v == 1){
			$("#groupmenu").val('');
			$("#mastermenu").val('');
			$("#advanceSet").hide();
			$("#advanceGroupSet").hide();
		}else{
			$("#advanceGroupSet").show();
		}
	}
</script>

<form method="post" action="<?php echo site_url() ?>settingmenu/<?php echo $action; ?>" class="form-horizontal">
	<input type="hidden" name="id_menu" value="<?php echo @$detail[0]['id_menu']?>">
	
	<div class="control-group">
		<label class="control-label" for="nama_menu">Nama menu</label>
		<div class="controls">
		  <input type="text" class="span5" name="nama_menu" value="<?php echo @$detail[0]['nama_menu']?>" >
		</div>
	</div>
	
	<div class="control-group">
		<label class="control-label" for="urut_menu">Urutan menu</label>
		<div class="controls">
		  <input type="text" class="span2" name="urut_menu" value="<?php echo @$detail[0]['urut_menu']?>" >
		</div>
	</div>
	
	<div class="control-group">
		<label class="control-label" for="type_menu">Type menu</label>
		<div class="controls">
			<?php $selected1 =  '' ?>
			<?php $selected2 =  '' ?>
			<?php $selected3 =  '' ?>
			<?php $selected4 =  '' ?>
			<select name="type_menu">
				<?php if (@$detail[0]['type_menu'] == 1):?>
					<?php $selected1 =  'selected="selected"' ?>
				<?php elseif (@$detail[0]['type_menu'] == 2) :?>
					<?php $selected2 =  'selected="selected"' ?>
				<?php elseif (@$detail[0]['type_menu'] == 3) :?>
					<?php $selected3 =  'selected="selected"' ?>
				<?php elseif (@$detail[0]['type_menu'] == 4) :?>
					<?php $selected3 =  'selected="selected"' ?>
				<?php else:?>
					<?php $selected1 =  '' ?>
					<?php $selected2 =  '' ?>
					<?php $selected3 =  '' ?>
					<?php $selected4 =  '' ?>
				<?php endif;?>
				
				<option value="0" >--</option>
				<option value="1" <?php echo $selected1 ?> >Single Content</option>
				<option value="2" <?php echo $selected2 ?> >Multi Content</option>
				<option value="3" <?php echo $selected3 ?> >Galeri</option>
				<option value="4" <?php echo $selected4 ?> >Saran</option>
			</select>
		</div>
	</div>
	
	<div class="control-group">
		<label class="control-label" for="master_menu">Master menu</label>
		<div class="controls" style="padding-top:5px">
			<?php 
				if(@$detail[0]['master_menu'] == 1){
					$checkYa = "checked";
					$checkTidak = "";
				}else{
					if($action == "save"){
						$checkYa = "checked";
						$checkTidak = "";
					}else{
						$checkYa = "";
						$checkTidak = "checked";
					}
				}
			?>
			<input type="radio" name="master_menu" value="1" onclick="getNilaiMaster(this.value);" <?php echo $checkYa; ?> >Ya</input>&nbsp;&nbsp;
			<input type="radio" name="master_menu" value="0" onclick="getNilaiMaster(this.value);" <?php echo $checkTidak; ?> >Tidak</input>
		</div>
	</div>
	
	<div id="advanceGroupSet">
		<div class="control-group">
			<label class="control-label" for="group_menu">Group menu</label>
			<div class="controls">
			
				<select id="groupmenu" name="group_menu" onChange="getNilai(this.value)">
					<?php if (@$detail[0]['group_menu'] == 1):?>
						<?php $selected =  'selected="selected"' ?>
					<?php else :?>
						<?php $selected =  '' ?>
					<?php endif;?>
				
					<option value="0">Tidak</option>
					<option value="1" <?php echo $selected ?> >Ya</option>
				</select>
			</div>
		</div>
		
		<div id="advanceSet">
			<div class="control-group">
				<label class="control-label" for="induk_menu">Master menu</label>
				<div class="controls">
					<select id="mastermenu" name="induk_menu">
						<option value="0">Pilih master</option>
						<?php if (@$mastermenu):?>
							<?php foreach ($mastermenu as $row):?>
								<?php if($row['id_menu'] == @$detail[0]['induk_menu']):?>
									<?php $selected =  'selected="selected"' ?>
								<?php else:?>
									<?php $selected =  '' ?>
								<?php endif;?>
								<option value="<?php echo $row['id_menu'] ?>" <?php echo $selected ?> ><?php echo $row['nama_menu'] ?></option>
							<?php endforeach?>
						<?php endif?>
					</select>
				</div>
			</div>
		</div>
	</div>
	
	<div class="control-group">
		<label class="control-label" for="enable_menu">Enable menu</label>
		<div class="controls" style="padding-top:5px">
			<?php 
				if(@$detail[0]['enable_menu'] == 1){
					$check = "checked";
				}else{
					if($action == "save"){
						$check = "checked";
					}else{
						$check = "";
					}
				}
			?>
			<input type="checkbox" name="enable_menu" value="1" <?php echo $check; ?> ></input>
		</div>
	</div>
	<div class="form-actions">
		<input type="submit" name="submit" value="Simpan" class="btn btn-primary"/>
		<a href="<?php echo site_url()?>settingmenu" class="btn">Batal</a>
	</div>
</form>
<?php $this->load->view('config/footer');?>